Imports System
Imports Microsoft.VisualBasic
  Partial Class settingsUser_aspx_vb
    Inherits System.Web.UI.Page
    Public Conn As Object ' ADODB.Connection
    Public fragusLeasingUserID As Object ' System.Object
    Public fragusLeasingUserTypeID As Object ' System.Object
    Public strJS As String 
    Public strSelectSubHeadline As String 
    Public strSelectSubJS As String 
    Public mobileGUI As Object ' System.Object
    Public coCompany As Object ' System.Object
    Public coStreet As Object ' System.Object
    Public coZipcode As Object ' System.Object
    Public coCity As Object ' System.Object
    Public coTelephone As Object ' System.Object
    Public coFax As Object ' System.Object
    Public coEmail As Object ' System.Object
    Public coHomepage As Object ' System.Object
    Public coCountry As Object ' System.Object
    Public coCin As Object ' System.Object
    Public RecSet As Object ' ADODB.Recordset
    Public strGrey As String 
    Public rowNumber As Integer 
    Public subDo As String 
    Public countryID As Object 
    Public country As Object ' System.Object
    Public username As Object 
    Public userID As Object 
    Public userType As Object ' System.Object
    Public userTypeID As Object 
    Public usr As String 
    Public pwd As String 
    Public dbUserTypeID As Object ' System.Object
    Public dbCountryID As Object ' System.Object
    Public dbUsername As Object ' System.Object
    Public dbUsr As Object ' System.Object
    Public dbPwd As Object ' System.Object
    Public dbUserCount As Object 
    Public Function dbOpen() As Object
        Conn = New ADODB.ConnectionClass()
        Conn.Open(ConfigurationManager.ConnectionStrings("DatabaseConnection").ToString())

    End Function

    Public Function dbClose() As Object
        Conn.Close()
        Conn = Nothing
    End Function

    Public Function Over() As Object
        Response.Write("<html>")
        Response.Write("<head>")
        Response.Write("<title>Fragus Leasing Systems - administration</title>")
        'Response.Write "<script language='JavaScript' src='fieldFocus.js'></script>"
        Response.Write("<link rel='stylesheet' href='style.css'>")
        Response.Write("<script type=""text/javascript"">" & vbCr)
        Response.Write("	  function OnLoadFunctions(){" & vbCr)
        Response.Write("	    //hide loading status..." & vbCr)
        Response.Write("	    document.getElementById(""loading"").style.display='none';" & vbCr)
        Response.Write("	    //show content" & vbCr)
        Response.Write("	    document.getElementById(""content"").style.display='block';" & vbCr)
        Response.Write("	    if (document.forms.length > 0) {" & vbCr)
        Response.Write("	      var field = document.forms[0];" & vbCr)
        Response.Write("	      for (i = 0; i < field.length; i++) {" & vbCr)
        Response.Write("		if ((field.elements[i].type == ""text"") || (field.elements[i].type == ""textarea"") || (field.elements[i].type.toString().charAt(0) == ""s"")) {" & vbCr)
        Response.Write("		  document.forms[0].elements[i].focus();" & vbCr)
        Response.Write("		  break;" & vbCr)
        Response.Write("		}" & vbCr)
        Response.Write("	      }" & vbCr)
        Response.Write("	    }" & vbCr)
        Response.Write("	  }" & vbCr)
        Response.Write("	</script>" & vbCr)
        Response.Write("</head>")
        Response.Write("<body OnLoad=""OnLoadFunctions()"">")
        Response.Write("<script type=""text/javascript"">" & vbCr)
        Response.Write("	  document.write('<div id=""loading""><center><img src=""gui/progressBar.gif""><br><br>System loading. Please wait...</center></div>');" & vbCr)
        Response.Write("	</script>" & vbCr)
        Response.Write("	<div id=""content"">" & vbCr)
        Response.Write("<script type=""text/javascript"">" & vbCr)
        Response.Write("	    //hide content" & vbCr)
        Response.Write("	    document.getElementById(""content"").style.display='none';" & vbCr)
        Response.Write("	  </script>" & vbCr)
        If CDbl(mobileGUI) = 0 Then 
            Response.Write("<script language='JavaScript' src='menu.js'></script>")
            Response.Write("<script language='JavaScript' src='menu_items.js'></script>")
            Response.Write("<script language='JavaScript' src='menu_tpl.js'></script>")
            Response.Write("<script language='JavaScript'>")
            Response.Write("new menu (MENU_ITEMS, MENU_POS);")
            Response.Write("</script>")
            Response.Write("<table height='100' width='100%' cellpadding='0' cellspacing='0' background='gui/menu_main.jpg'>")
            Response.Write("<tr>")
            Response.Write("<td align='left'><img src='gui/menu_left.jpg'></td>")
            Response.Write("<td align='right'><img src='gui/menu_right.jpg'></td>")
            Response.Write("</tr>")
            Response.Write("</table>")
        Else
            Response.Write("<table height='20' width='100%' cellpadding='0' cellspacing='0'>")
            Response.Write("<tr>")
            Response.Write("<td class='headline'><a href='userInside.aspx'>[GO TO MENU]</a><hr class='hrHeadline'></td>")
            Response.Write("</tr>")
            Response.Write("</table>")
        End IF
    End Function

    Public Function OverPrint() As Object
        Response.Write("<html>")
        Response.Write("<head>")
        Response.Write("<title>FLS - Print</title>")
        Response.Write("<link href='style.css' rel='stylesheet' type='text/css'>")
        Response.Write("  <style media=""print"">" & vbCr)
        Response.Write("  .noprint { display: none }" & vbCr)
        Response.Write("  </style>" & vbCr)
        Response.Write("<script defer>" & vbCr)
        Response.Write("  function window.onload() {" & vbCr)
        Response.Write("    factory.printing.header = """"" & vbCr)
        Response.Write("    factory.printing.footer = """"" & vbCr)
        Response.Write("    factory.printing.portrait = true" & vbCr)
        Response.Write("  }" & vbCr)
        Response.Write("    function printWindow() {" & vbCr)
        Response.Write("    bV = parseInt(navigator.appVersion);" & vbCr)
        Response.Write("    if (bV >= 4) window.print();return true" & vbCr)
        Response.Write("  }" & vbCr)
        Response.Write("  </script>" & vbCr)
        Response.Write("<object id=""factory"" viewastext  style=""display:none""" & vbCr)
        Response.Write("    classid=""clsid:1663ed61-23eb-11d2-b92f-008048fdd814""" & vbCr)
        Response.Write("    codebase=""smsx.cab#Version=6,3,435,20"">" & vbCr)
        Response.Write("  </object>" & vbCr)
        Response.Write("</head>")
        Response.Write("<body>")
    End Function

    Public Function Under() As Object
        Response.Write("</div>")
        Response.Write("</body>")
        Response.Write("</html>")
    End Function

    Public Function CompanyAddressSQL() As Object
        dbOpen()
        RecSet = Conn.Execute("Select co.company, co.street, co.zipcode, co.city, co.telephone, co.fax, co.email, co.homepage, co.cin, c.country From (tblCompany co INNER Join tblCountry c ON c.countryID = co.companyID) Where co.countryID = " & countryID & "")
        If Not RecSet.EOF Then 
            coCompany = RecSet.Fields("company").Value
            coStreet = RecSet.Fields("street").Value
            coZipcode = RecSet.Fields("zipcode").Value
            coCity = RecSet.Fields("city").Value
            coTelephone = RecSet.Fields("telephone").Value
            coFax = RecSet.Fields("fax").Value
            coEmail = RecSet.Fields("email").Value
            coHomepage = RecSet.Fields("homepage").Value
            coCountry = RecSet.Fields("country").Value
            coCin = RecSet.Fields("cin").Value
        End IF
        RecSet.Close()
        RecSet = Nothing
        dbClose()
    End Function

    Public Function CompanyAddressPrintAllSQL() As Object
        RecSet = Conn.Execute("Select co.company, co.street, co.zipcode, co.city, co.telephone, co.fax, co.email, co.homepage, co.cin, c.country From (tblCompany co INNER Join tblCountry c ON c.countryID = co.companyID) Where co.countryID = " & countryID & "")
        If Not RecSet.EOF Then 
            coCompany = RecSet.Fields("company").Value
            coStreet = RecSet.Fields("street").Value
            coZipcode = RecSet.Fields("zipcode").Value
            coCity = RecSet.Fields("city").Value
            coTelephone = RecSet.Fields("telephone").Value
            coFax = RecSet.Fields("fax").Value
            coEmail = RecSet.Fields("email").Value
            coHomepage = RecSet.Fields("homepage").Value
            coCountry = RecSet.Fields("country").Value
            coCin = RecSet.Fields("cin").Value
        End IF
        RecSet.Close()
        RecSet = Nothing
    End Function

    Public Function CompanyAddress() As Object
        Response.Write("<table cellpadding='0' cellspacing='0'>")
        Response.Write("<tr><td colspan='2'><img src='gui/fragus_logo.jpg'></td></tr>")
        Response.Write("<tr><td><br></td></tr>")
        Response.Write("<tr><td colspan='2' class='printBold'>" & coCompany & "</td></tr>")
        Response.Write("<tr><td><br></td></tr>")
        Response.Write("<tr><td class='printRegular' valign='top'>Address:</td><td class='printRegular'>" & coStreet & "<br>" & coZipcode & " " & coCity & "<br>" & coCountry & "</td></tr>")
        Response.Write("<tr><td class='printRegular'>Phone:</td><td class='printRegular'>" & coTelephone & "</td></tr>")
        Response.Write("<tr><td class='printRegular'>Fax:</td><td class='printRegular'>" & coFax & "</td></tr>")
        Response.Write("<tr><td class='printRegular'>E-mail:</td><td class='printRegular'>" & coEmail & "</td></tr>")
        Response.Write("<tr><td class='printRegular'>Homepage:</td><td class='printRegular'>" & coHomepage & "</td></tr>")
        Response.Write("<tr><td class='printRegular'>Company ID:</td><td class='printRegular'>" & coCin & "</td></tr>")
        Response.Write("<tr><td><br></td></tr>")
        Response.Write("<tr><td colspan='2' class='printRegular'>" & coCompany & ", a subsidiary to AB Svensk Bilgaranti</td></tr>")
        Response.Write("</table>")
    End Function

    Public Function checkFields() As Object
        Response.Write("<script type=""text/javascript"">" & vbCr)
        Response.Write("<!--" & vbCr)
        Response.Write("function _(id) {" & vbCr)
        Response.Write("    return document.getElementById(id);" & vbCr)
        Response.Write("}" & vbCr)
        Response.Write("function scrollToError(elemId)" & vbCr)
        Response.Write("{" & vbCr)
        Response.Write("    if (window.scrollTo) {" & vbCr)
        Response.Write("	var el = _(elemId);" & vbCr)
        Response.Write("	var pos = 0;" & vbCr)
        Response.Write("	// Calculate the position" & vbCr)
        Response.Write("	while (el) {" & vbCr)
        Response.Write("            pos += el.offsetTop;" & vbCr)
        Response.Write("            el = el.offsetParent;" & vbCr)
        Response.Write("	}" & vbCr)
        Response.Write("	if (typeof(document.body.topMargin) == 'number')" & vbCr)
        Response.Write("            pos += document.body.topMargin;" & vbCr)
        Response.Write("        if (pos > 100)" & vbCr)
        Response.Write("            pos -= 100;" & vbCr)
        Response.Write("        " & vbCr)
        Response.Write("	// Scroll" & vbCr)
        Response.Write("        window.scrollTo(0, pos);" & vbCr)
        Response.Write("    }" & vbCr)
        Response.Write("    // Focus " & vbCr)
        Response.Write("    _(elemId).focus();" & vbCr)
        Response.Write("} " & vbCr)
        Response.Write("// sorted in top-to-bottom order" & vbCr)
        Response.Write("var checks = [")
        Response.Write(strJS)
        Response.Write("];" & vbCr)
        Response.Write("var error;" & vbCr)
        Response.Write("var firstfield;" & vbCr)
        Response.Write("function badfield( _field )" & vbCr)
        Response.Write("{" & vbCr)
        Response.Write("    _(""error_""+_field).style.display = 'block';" & vbCr)
        Response.Write("    if (!error) {" & vbCr)
        Response.Write("        firstfield = _field;" & vbCr)
        Response.Write("        error=true;" & vbCr)
        Response.Write("    }" & vbCr)
        Response.Write("}" & vbCr)
        Response.Write("function checkFields()" & vbCr)
        Response.Write("{" & vbCr)
        Response.Write("    error = false;" & vbCr)
        Response.Write("    firstfield = null;" & vbCr)
        Response.Write("    try {" & vbCr)
        Response.Write("        for (i=0; i<checks.length; i++) {" & vbCr)
        Response.Write("            var field = checks[i][0];" & vbCr)
        Response.Write("            var condition = checks[i][1];" & vbCr)
        Response.Write("            var value = _(field).value;" & vbCr)
        Response.Write("            " & vbCr)
        Response.Write("            // check that field is non-empty" & vbCr)
        Response.Write("            if (value && value.length < 1) {" & vbCr)
        Response.Write("                badfield(field);" & vbCr)
        Response.Write("                continue;" & vbCr)
        Response.Write("            }" & vbCr)
        Response.Write("            // check that field is correct" & vbCr)
        Response.Write("            expr = ""'"" + value + ""'"" + condition;" & vbCr)
        Response.Write("            if (eval(expr) == true) {" & vbCr)
        Response.Write("                badfield(field);" & vbCr)
        Response.Write("                continue;" & vbCr)
        Response.Write("            }" & vbCr)
        Response.Write("            _(""error_""+field).style.display = 'none';" & vbCr)
        Response.Write("        }" & vbCr)
        Response.Write("        if (error)" & vbCr)
        Response.Write("            scrollToError(firstfield);" & vbCr)
        Response.Write("    }" & vbCr)
        Response.Write("    catch (e) {" & vbCr)
        Response.Write("        //alert(e.message ? e.message : e.description);" & vbCr)
        Response.Write("    }" & vbCr)
        Response.Write("        " & vbCr)
        Response.Write("    return !error;" & vbCr)
        Response.Write("}" & vbCr)
        Response.Write("-->" & vbCr)
        Response.Write("</script>" & vbCr)
    End Function

    Public Function insertFonts() As Object
        Response.Write("<script type=""text/javascript"">" & vbCr)
        Response.Write("<!--")
        Response.Write("var carret=null,fieldobj=null,ie=(document.selection&&document.selection.createRange);")
        Response.Write("function storepos(obj){ ")
        Response.Write("   fieldobj=obj; carret=(ie)?document.selection.createRange():null; ")
        Response.Write("}")
        Response.Write("function saveScrollCoordinates()")
        Response.Write("{")
        Response.Write("	//scrollx = (document.all)?document.body.scrollLeft:window.pageXOffset;")
        Response.Write("	//scrolly = (document.all)?document.body.scrollTop:window.pageYOffset;")
        Response.Write("}")
        Response.Write("function insertAtCarret(str){")
        Response.Write("   if(!fieldobj) return null;")
        Response.Write("   if (carret){")
        Response.Write("      carret.text=str; carret.select();")
        Response.Write("   } else if(document.getElementById&&!ie) {")
        Response.Write("      fieldobj.value=fieldobj.value.substring(0,fieldobj.selectionStart)+str+fieldobj.value.substring(fieldobj.selectionEnd);")
        Response.Write("      fieldobj.focus();")
        Response.Write("   } else {")
        Response.Write("      fieldobj.value+=str;")
        Response.Write("      fieldobj.focus();")
        Response.Write("   }")
        Response.Write("}")
        Response.Write("-->")
        Response.Write("</script>" & vbCr)
    End Function

    Public Function selectSub() As Object
        Response.Write("<script language=""JavaScript"">" & vbCr)
        Response.Write("var DomYes=document.getElementById?1:0;" & vbCr)
        Response.Write("function set_child_listbox(parentObject,childObject,childArray,spanToHide) {" & vbCr)
        Response.Write("	//Clear child listbox" & vbCr)
        Response.Write("	for(var i=childObject.length;i>0;i--) {" & vbCr)
        Response.Write("		childObject.options[i] = null;" & vbCr)
        Response.Write("	} " & vbCr)
        Response.Write("	" & vbCr)
        Response.Write("	childObject.options[0] = new Option("" ")
        Response.Write(strSelectSubHeadline)
        Response.Write(" "","""");" & vbCr)
        Response.Write("	var sel_index = parentObject.options[parentObject.selectedIndex].value;" & vbCr)
        Response.Write("	if (sel_index == """") {" & vbCr)
        Response.Write("		childObject.disabled = true;" & vbCr)
        Response.Write("	} else {" & vbCr)
        Response.Write("		childObject.disabled = false;" & vbCr)
        Response.Write("		var childIndex = 1;" & vbCr)
        Response.Write("		for (i = 0; i < childArray.length; i++) {" & vbCr)
        Response.Write("			if (childArray[i][1] == sel_index) {" & vbCr)
        Response.Write("				childObject.options[childIndex] = new Option(childArray[i][2], childArray[i][0]);" & vbCr)
        Response.Write("				childIndex++;" & vbCr)
        Response.Write("			}" & vbCr)
        Response.Write("		}" & vbCr)
        Response.Write("	}" & vbCr)
        Response.Write("	//Select first option" & vbCr)
        Response.Write("	childObject.selectedIndex = 0;" & vbCr)
        Response.Write("}" & vbCr)
        Response.Write("var Product = new Array(")
        Response.Write(strSelectSubJS)
        Response.Write(");" & vbCr)
        Response.Write("</script>" & vbCr)
    End Function


  End Class
